import logging
import time

from kazoo.client import KazooClient

logging.basicConfig()

zk = KazooClient(hosts='192.168.99.100:2181')
zk.start()
print("success!")
basePath = '/datalake'

lastTimeChildren = zk.get_children(basePath)


@zk.ChildrenWatch(basePath)
def my_func(children):
    if len(lastTimeChildren) < len(children):
        print("add")

    elif len(lastTimeChildren) > len(children):
        print("delete")

    print(type(lastTimeChildren))


    print("Children are %s" % children)


while True:
    time.sleep(10)
